import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Stack;

public class project {
    public int maxmiumScore(int[] cards, int cnt) {
        Arrays.sort(cards);
        ArrayList<Integer> odd=new ArrayList<>();
        ArrayList<Integer> even=new ArrayList<>();
        odd.add(0);
        even.add(0);
        for(int i=cards.length-1;i>=0;i--){
            if(cards[i]%2==0){
                even.add(even.get(even.size()-1)+cards[i]);
            }else{
                odd.add(odd.get(odd.size()-1)+cards[i]);
            }
        }
        int k=0;
        int max=0;
        while(k<=cnt){
            if(k<odd.size()&&cnt-k<even.size()&&(odd.get(k)+even.get(cnt-k))%2==0){
                max=Math.max(max,(odd.get(k)+even.get(cnt-k)));
            }
            k++;
        }
        return max;
    }








    public List<String> stringMatching(String[] words) {
        List<String> list=new ArrayList<>();
        for(int i=0;i<words.length;i++){
            for(int j=0;j<words.length;j++){
                if(i!=j){
                    if(words[i].contains(words[j])&&!list.contains(words[j])){
                        list.add(words[j]);
                    }
                }
            }
        }
        return list;
    }









    public int[] dailyTemperatures(int[] temperatures) {
        int[] arr=new int[temperatures.length];
        Stack<Integer> stack=new Stack<>();
        int i=0;
        while(i<temperatures.length){
            if(stack.isEmpty()||temperatures[stack.peek()]>=temperatures[i]){
                stack.push(i++);
            }else{
                int tmp=stack.pop();
                arr[tmp]=i-tmp;
            }
        }
        return arr;
    }










    public int[] dailyTemperatures1(int[] temperatures) {
        int[] arr=new int[temperatures.length];
        Stack<Integer> stack=new Stack<>();
        int i=0;
        while(i<temperatures.length){
            if(stack.isEmpty()||temperatures[stack.peek()]>=temperatures[i]){
                stack.push(i++);
            }else{
                int tmp=stack.pop();
                arr[tmp]=i-tmp;
            }
        }
        return arr;
    }
}
